package com.tedu.api;

import org.junit.Test;

public class 作业 {
    // ①
    @Test
    public void testLength() {
        String s = "HelloJava";
        System.out.println(s.length());
    }

    //②
    @Test
    public void testIndexOf() {
        String str = "HelloJava";
        int index = str.indexOf("o");
        System.out.println("o所在位置：" + index);
        //③
        index= str.indexOf("o",5);
        System.out.println(index);
    }


    //④
    @Test
    public void testSubString() {
        String url = "HelloJava";
        String s = url.substring(0, 5);
        System.out.println("截取后的子字符串：" + s);

    }
    //⑤
    @Test
    public void testSubString1() {
        String url = "HelloJava";
        String s = url.substring(5, 9);
        System.out.println("截取后的子字符串：" + s);

    }
    //⑥
    @Test
    public void testTrim(){
        String str=" Hello ";
        str=str.trim();
        System.out.println(str);
    }
    //⑦
    @Test
    public void testCharAT(){
        String str="HelloJava";
        char c=str.charAt(5);
        System.out.println("获取的字符是："+c);
    }
    //⑧
    @Test
    public void testUL(){
        String str="HelloJava";//判断：大小写分明  需求：去空格，转大小写
        str=str.toLowerCase();
        System.out.println("转换为小写："+str);
        str=str.toUpperCase();
        System.out.println("转换为大写："+str);
    }
}


